<template>
	<view class="content">
		<div class="pos-rel" v-if="loading">



			<!-- 内容 -->
			<div class="main">
				<div class="contentBox">
					<div v-for="(item, index) in tutorList" :key="index" class="tutor-item mb-8"
						@click="toDetail(item)">
						<image class="avator" :src="baseUrl + item.carouselImageUrls" />
						<div class="ml-22">
							<div class="flex align-center mt-6 lh-44">
								<div class="font-500 fontS-28 colorMainX">{{ item.tutorName }}</div>
								<div class="color-6 fontS22 ml-20">已服务{{ item.servePeople }}人</div>
							</div>
							<div class="label">{{ item.parentLabelName }}/{{ item.labelName }}</div>
						</div>
						<div class="flex align-center ml-auto">
							<div class="color-red flex align-end  fontS32 font-weight"><span
									class="fontS24 mr-5">¥</span>{{
										item.price
									}}</div>
							<div class="iconfont icon-youjiantou ml-20 color-9"></div>
						</div>
					</div>
				</div>
			</div>

		</div>

	</view>
</template>

<script>

import {
	findServePersonalDetailApp,
	findServeDetail
} from "@/api/index";
import {
	tutorList,
} from "@/api/serve";

export default {

	data() {
		return {
			headerHeight: 0, // 用于存储头部高度
			baseUrl: getApp().globalData.baseUrl,
			title: '人法财',
			isShowbar: false,
			isBack: false,
			serviceDetail: null,
			loading: false,

			swiperList: [],
			iconList: [],
			custom: null,
			navTop: null,
			serveId: null,
			tutorList: []



		};
	},
	computed: {
		userInfo() {
			return this.$store.getters.userInfo;
		},
	},
	onShareTimeline() {
		return {
			title: this.shareLine.title,
			// imageUrl: this.shareLine.imageUrl,
		}
	},
	mounted() {

		// 动态获取头部高度
		const query = uni.createSelectorQuery().in(this);
		query.select('.header').boundingClientRect(data => {
			if (data) {
				console.log(data)
				this.headerHeight = data.height;
			}
		}).exec();

	},
	onShareAppMessage(res) {
		console.log(res)

		if (res.from === 'button') {
			return {
				title: this.shareLine.title,
				path: '/pages/index/index',
				// imageUrl: this.weeklyDetailInfo.coverUrl,
				success(res) {
					uni.showToast({
						title: '分享成功'
					})
				},
				fail(res) {
					uni.showToast({
						title: '分享失败',
						icon: 'none'
					})
				}
			}
		} else {
			return {
				title: this.shareLine.title,
				path: '/pages/index/index',
				// imageUrl: this.houseListInfo.houseCover,
				success(res) {
					uni.showToast({
						title: '分享成功'
					})
				},
				fail(res) {
					uni.showToast({
						title: '分享失败',
						icon: 'none'
					})
				}
			}
		}
	},

	async onHide() {
	},
	async onLoad(option) {
		console.log(option)
		let custom = wx.getMenuButtonBoundingClientRect()
		this.btnRight = uni.upx2px(30) + custom.width

		getApp().globalData.dynamicObj = null;
		this.custom = custom
		this.navTop = custom.top - this.statusBarHeight
		console.log(custom, this.navTop)
		this.serveId = option.serveId
		await this.getServiceDetail(option.serveId)
		await this.getTutorList()
	},

	async onShow() {




	},

	methods: {
		wxScale() {
			uni.previewImage({
				urls: [
					"https://oss-prod.xtrip.vip/common/20241011102729.png?x-oss-process=image/quality,q_80/format,jpg"
				], //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了

			})
		},
		// 导师列表
		async getTutorList() {
			const {
				rows
			} = await tutorList({
				serveId: this.serveId
			});
			this.tutorList = rows
			this.loading = true
		},
		// 个人端详情
		async getServiceDetail(id) {

			const {
				data
			} = await findServePersonalDetailApp(id);
			this.serviceDetail = data
			this.loading = true
		},
		toDetail(item) {
			uni.navigateTo({
				url: `/pages/service/tutorDetail?serveId=${this.serveId}&tutorId=${item.tutorId}`
			})
		},
		// 个人端icon
		async getIconListPr() {
			const {
				data
			} = await findServeIconListPerApp();
			this.iconList = data

		},
		// 跳转导师
		goTutor() {
			uni.navigateTo({
				url: '/pages/service/tutor'
			})
		},
		// 跳转支付
		CreatOrder() {

		}
	},

	onReachBottom() {
	},
	onPullDownRefresh() {
	},
};
</script>

<style lang="less" scoped>
@import url(index.less);

page {
	background-color: #f7f7f7 !important;
}

.content {

	padding-bottom: calc(constant(safe-area-inset-bottom) + 108upx);
	/*兼容 IOS<11.2*/
	padding-bottom: calc(env(safe-area-inset-bottom) + 108upx);
	/*兼容 IOS>11.2*/

}

.contentBox {
	// padding: 20rpx;
}

.tutor-item {
	padding: 30upx 20upx;
	background: #FFFFFF;
	border-radius: 8rpx;
	display: flex;
	align-items: center;

	.avator {
		width: 104upx;
		height: 104upx;
		border-radius: 8rpx;
	}

	.label {
		margin-top: 20upx;
		height: 36upx;
		background: #F2F2F2;
		border-radius: 4upx;
		line-height: 36upx;
		padding: 0 14rpx;
		font-size: 20rpx;
		color: #666666;
	}

}
</style>